package com.emm.yixun.website.controller.system;
//框架包
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

//变化的引用
import com.emm.yixun.common.model.TelRecord;
import com.emm.yixun.common.model.User;
import com.emm.yixun.common.model.dto.TelRecordExtendDto;
import com.emm.yixun.common.page.Page;
//common
import com.emm.yixun.common.page.PageUtil;
import com.emm.yixun.system.service.TelRecordServiceFacade;
import com.emm.yixun.website.common.utils.base.Const;
import com.emm.yixun.website.common.utils.security.ShiroUtil;
import com.emm.yixun.website.controller.base.BaseController;
//website

import cn.jpush.api.utils.StringUtils;

@Controller
@RequestMapping("/system/telRecordAnalyze/")
public class TelRecordAnalyzeController extends BaseController<TelRecord>{
	
	@Autowired
	private TelRecordServiceFacade telRecordServiceFacade;
	
	/**
	 * 会员通话情况汇总
	 * @param map
	 * @return
	 */
	@RequestMapping(value="usercallsummary")
	public String userCallSummary(ModelMap map){
		if(doSecurityIntercept(Const.RESOURCES_TYPE_MENU)){
			//查询菜单按钮权限
			User user=ShiroUtil.getCurrentUser();
			map.put("permitBtn", getPermitBtn(Const.RESOURCES_TYPE_FUNCTION));		
			map.put("userDepartmentPath", user.getUserDepartmentPath());
			map.put("currUserId", user.getId());
			map.put("currUserName", user.getUserName());
			return "/system/telRecord/usercallsummary/index";
		}
		return Const.NO_AUTHORIZED_URL;
	}
	
	/**
	 * 员工通话量汇总列表
	 * @param dto
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	@RequestMapping(value="summary_list", method=RequestMethod.POST)
	@ResponseBody
    public Page<TelRecordExtendDto> summaryList(TelRecordExtendDto dto,Integer limit,Integer page){
		Page<TelRecordExtendDto> response = new Page<TelRecordExtendDto>();
		/*
    	 *1.判断权限 
    	 *2.调用分页查询接口
    	 *3.返回信息
    	*/
        //if(ar.setNoAuth(doSecurityIntercept(Const.RESOURCES_TYPE_BUTTON,"system:telRecord:list"))){
        	try {
        		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        		if(StringUtils.isNotEmpty(dto.getStartTimeBeforeStr())){
        			String startTimeBeforeStr = dto.getStartTimeBeforeStr();
        			startTimeBeforeStr += " 00:00:00";
        			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
        		}
        		if(StringUtils.isNotEmpty(dto.getStartTimeAfterStr())){
        			String startTimeAfterStr = dto.getStartTimeAfterStr();
        			startTimeAfterStr += " 23:59:59";
        			dto.setStartTimeAfter(sdf.parse(startTimeAfterStr));
        		}
        		User user=ShiroUtil.getCurrentUser();
        		dto.setMerchantId(user.getMerchantId());
        		response = telRecordServiceFacade.findSummaryListPageByDto(dto, PageUtil.begin(page, limit),limit);
        		List<TelRecordExtendDto> recordDtoList = response.getRows();
        		if(null != recordDtoList && recordDtoList.size() > 0){
        			for(TelRecordExtendDto recordDto: recordDtoList){
        				int avgTalkTime = 0;
        				if(null != recordDto.getAvgTalkTime()){
        					avgTalkTime = (int)Double.parseDouble(recordDto.getAvgTalkTime());
        				}
        				recordDto.setAvgTalkTime(changeSecondsToHMS(avgTalkTime));
        				
        				int totalTalkTime = 0;
        				if(null != recordDto.getTotalTalkTime()){
        					totalTalkTime = (int)Double.parseDouble(recordDto.getTotalTalkTime());
        				}
        				recordDto.setTotalTalkTime(changeSecondsToHMS(totalTalkTime));
        			}
        			response.setRows(recordDtoList);
        		}
			} catch (Exception e) {
				logger.error(e.toString(),e);
			}
    	//}
    	return response;
    }
	
	/**
	 * 会员通话量分析 
	 * @param map
	 * @return
	 */
	@RequestMapping(value="usercallanalyze")
	public String userCallAnalyze(ModelMap map){
		if(doSecurityIntercept(Const.RESOURCES_TYPE_MENU)){
			//查询菜单按钮权限
			map.put("permitBtn", getPermitBtn(Const.RESOURCES_TYPE_FUNCTION));		
			return "/system/telRecord/usercallanalyze/index";
		}
		return Const.NO_AUTHORIZED_URL;
	}
	
	/**
	 * 员工通话记录日分析
	 * @param dto
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	@RequestMapping(value="analyze_daily_list", method=RequestMethod.POST)
	@ResponseBody
    public Page<TelRecordExtendDto> analyzeDailyList(TelRecordExtendDto dto,Integer limit,Integer page){
		Page<TelRecordExtendDto> response = new Page<TelRecordExtendDto>();
    	/*
    	 *1.判断权限 
    	 *2.调用分页查询接口
    	 *3.返回信息
    	*/
		try {
			//查询多少天的数据
			int searchDays = 7;
			Calendar beforeCalendar = Calendar.getInstance();
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    		if(StringUtils.isNotEmpty(dto.getStartTimeAfterStr())){
    			String startTimeAfterStr = dto.getStartTimeAfterStr();
    			startTimeAfterStr += " 23:59:59";
    			dto.setStartTimeAfter(sdf.parse(startTimeAfterStr));
    			
    			Calendar calendar = Calendar.getInstance();
    			calendar.setTime(dto.getStartTimeAfter());
    			calendar.add(Calendar.DAY_OF_MONTH, -6);
    			int year = calendar.get(Calendar.YEAR);
    			int month = calendar.get(Calendar.MONTH) + 1;
    			int day = calendar.get(Calendar.DAY_OF_MONTH);
    			String startTimeBeforeStr = year+"-"+month+"-"+day + " 00:00:00";
    			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
    			beforeCalendar = calendar;
    		}else{
    			Calendar calendar = Calendar.getInstance();

    			int year = calendar.get(Calendar.YEAR);
    			int month = calendar.get(Calendar.MONTH) + 1;
    			int day = calendar.get(Calendar.DAY_OF_MONTH);
    			String startTimeAfterStr = year+"-"+month+"-"+day + " 23:59:59";
    			dto.setStartTimeAfter(sdf.parse(startTimeAfterStr));
    			
    			calendar.setTime(dto.getStartTimeAfter());
    			calendar.add(Calendar.DAY_OF_MONTH, -6);
    			year = calendar.get(Calendar.YEAR);
    			month = calendar.get(Calendar.MONTH) + 1;
    			day = calendar.get(Calendar.DAY_OF_MONTH);
    			String startTimeBeforeStr = year+"-"+month+"-"+day + " 00:00:00";
    			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
    			beforeCalendar = calendar;
    		}
    		//总数、拨通数、未拨通数
    		if(StringUtils.isNotEmpty(dto.getCallCheck())){
    			if(dto.getCallCheck().indexOf("0") >= 0){
    				dto.setCallTotalCheck("0");
    			}
				if(dto.getCallCheck().indexOf("1") >= 0){
    				dto.setCallInCheck("1");
    			}
				if(dto.getCallCheck().indexOf("2") >= 0){
    				dto.setCallOutCheck("2");
    			}
    		}else{
    			dto.setCallTotalCheck("0");
    			dto.setCallInCheck("1");
    			dto.setCallOutCheck("2");
    		}
    		//将要查询的日期存入Dto中
    		dto = setSearchDays(dto, beforeCalendar, searchDays);
    		User user=ShiroUtil.getCurrentUser();
    		dto.setMerchantId(user.getMerchantId());
    		response = telRecordServiceFacade.findDailyPageByDto(dto, PageUtil.begin(page, limit),limit);
    		List<TelRecordExtendDto> recordDtoList = response.getRows();
    		if(null != recordDtoList && recordDtoList.size() > 0){
    			for(TelRecordExtendDto recordDto: recordDtoList){
    				recordDto.setDayOneTime(dto.getDayOneTime());
    				recordDto.setDayTwoTime(dto.getDayTwoTime());
    				recordDto.setDayThreeTime(dto.getDayThreeTime());
    				recordDto.setDayFourTime(dto.getDayFourTime());
    				recordDto.setDayFiveTime(dto.getDayFiveTime());
    				recordDto.setDaySixTime(dto.getDaySixTime());
    				recordDto.setDaySevenTime(dto.getDaySevenTime());
    			}
    			response.setRows(recordDtoList);
    		}
		} catch (Exception e) {
			logger.error(e.toString(),e);
		}
    	return response;
    }
	
	/**
	 * 员工通话记录周(周一至周日)分析
	 * @param dto
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	@RequestMapping(value="analyze_week_list", method=RequestMethod.POST)
	@ResponseBody
    public Page<TelRecordExtendDto> analyzeWeekList(TelRecordExtendDto dto,Integer limit,Integer page){
		Page<TelRecordExtendDto> response = new Page<TelRecordExtendDto>();
    	/*
    	 *1.判断权限 
    	 *2.调用分页查询接口
    	 *3.返回信息
    	*/
		try {
			//查询多少天的数据
			int searchWeeks = 4;
			Calendar beforeCalendar = Calendar.getInstance();
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    		if(StringUtils.isNotEmpty(dto.getStartTimeAfterStr())){
    			String startTimeAfterStr = dto.getStartTimeAfterStr();
    			startTimeAfterStr += " 23:59:59";
    			Calendar calendar = Calendar.getInstance();
    			calendar.setTime(sdf.parse(startTimeAfterStr));
    			if(calendar.SUNDAY != calendar.get(Calendar.DAY_OF_WEEK)){
    				//不是星期天,将日期往后退到星期天
    				calendar.add(Calendar.DAY_OF_MONTH, 8-calendar.get(Calendar.DAY_OF_WEEK));
    			}
    			//周日作为每个星期的最后一天
    			int year = calendar.get(Calendar.YEAR);
    			int month = calendar.get(Calendar.MONTH) + 1;
    			int day = calendar.get(Calendar.DAY_OF_MONTH);
    			startTimeAfterStr = year + "-" + month + "-" + day + " 23:59:59";
    			dto.setStartTimeAfter(sdf.parse(startTimeAfterStr));
    			
    			//日期减去27天,4个自然周
    			calendar.setTime(dto.getStartTimeAfter());
    			calendar.add(Calendar.DAY_OF_MONTH, -27);
    			year = calendar.get(Calendar.YEAR);
    			month = calendar.get(Calendar.MONTH) + 1;
    			day = calendar.get(Calendar.DAY_OF_MONTH);
    			String startTimeBeforeStr = year+"-"+month+"-"+day + " 00:00:00";
    			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
    			beforeCalendar = calendar;
    		}else{
    			Calendar calendar = Calendar.getInstance();
    			if(calendar.SUNDAY != calendar.get(Calendar.DAY_OF_WEEK)){
    				//不是星期天,将日期往后退到星期天
    				calendar.add(Calendar.DAY_OF_MONTH, 8-calendar.get(Calendar.DAY_OF_WEEK));
    			}
    			int year = calendar.get(Calendar.YEAR);
    			int month = calendar.get(Calendar.MONTH) + 1;
    			int day = calendar.get(Calendar.DAY_OF_MONTH);
    			String startTimeAfterStr = year+"-"+month+"-"+day + " 23:59:59";
    			dto.setStartTimeAfter(sdf.parse(startTimeAfterStr));
    			
    			calendar.setTime(dto.getStartTimeAfter());
    			calendar.add(Calendar.DAY_OF_MONTH, -27);
    			year = calendar.get(Calendar.YEAR);
    			month = calendar.get(Calendar.MONTH) + 1;
    			day = calendar.get(Calendar.DAY_OF_MONTH);
    			String startTimeBeforeStr = year+"-"+month+"-"+day + " 00:00:00";
    			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
    			beforeCalendar = calendar;
    		}
    		//总数、拨通数、未拨通数
    		if(StringUtils.isNotEmpty(dto.getCallCheck())){
    			if(dto.getCallCheck().indexOf("0") >= 0){
    				dto.setCallTotalCheck("0");
    			}
				if(dto.getCallCheck().indexOf("1") >= 0){
    				dto.setCallInCheck("1");
    			}
				if(dto.getCallCheck().indexOf("2") >= 0){
    				dto.setCallOutCheck("2");
    			}
    		}else{
    			dto.setCallTotalCheck("0");
    			dto.setCallInCheck("1");
    			dto.setCallOutCheck("2");
    		}
    		//将要查询的日期存入Dto中
    		dto = setSearchWeeks(dto, beforeCalendar, searchWeeks);
    		beforeCalendar.setTime(dto.getStartTimeBefore());
    		dto = setSearchWeeksRange(dto, beforeCalendar, searchWeeks);
    		User user=ShiroUtil.getCurrentUser();
    		dto.setMerchantId(user.getMerchantId());
    		response = telRecordServiceFacade.findWeekPageByDto(dto, PageUtil.begin(page, limit),limit);
    		List<TelRecordExtendDto> recordDtoList = response.getRows();
    		if(null != recordDtoList && recordDtoList.size() > 0){
    			for(TelRecordExtendDto recordDto: recordDtoList){
    				recordDto.setWeekOneTimeRange(dto.getWeekOneTimeRange());
    				recordDto.setWeekTwoTimeRange(dto.getWeekTwoTimeRange());
    				recordDto.setWeekThreeTimeRange(dto.getWeekThreeTimeRange());
    				recordDto.setWeekFourTimeRange(dto.getWeekFourTimeRange());
    			}
    			response.setRows(recordDtoList);
    		}
		} catch (Exception e) {
			logger.error(e.toString(),e);
		}
    	return response;
    }
	
	/**
	 * 员工通话记录月分析
	 * @param dto
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	@RequestMapping(value="analyze_month_list", method=RequestMethod.POST)
	@ResponseBody
    public Page<TelRecordExtendDto> analyzeMonthList(TelRecordExtendDto dto,Integer limit,Integer page){
		Page<TelRecordExtendDto> response = new Page<TelRecordExtendDto>();
    	/*
    	 *1.判断权限 
    	 *2.调用分页查询接口
    	 *3.返回信息
    	*/
		try {
			//查询多少天的数据
			int searchMonth = 12;
			Calendar beforeCalendar = Calendar.getInstance();
    		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    		if(StringUtils.isNotEmpty(dto.getStartTimeAfterStr())){
    			String tempTime = "";
    			String startTimeAfterStr = dto.getStartTimeAfterStr();
    			tempTime = startTimeAfterStr;
    			startTimeAfterStr += "-01 23:59:59";
    			
    			Calendar calendar = Calendar.getInstance();
    			calendar.setTime(sdf.parse(startTimeAfterStr));
    			tempTime = tempTime + "-" + calendar.getActualMaximum(Calendar.DAY_OF_MONTH) + " 23:59:59";
    			dto.setStartTimeAfter(sdf.parse(tempTime));
    			
    			calendar.setTime(dto.getStartTimeAfter());
    			calendar.add(Calendar.MONTH, -11);
    			int year = calendar.get(Calendar.YEAR);
    			int month = calendar.get(Calendar.MONTH) + 1;
    			int day = 1;
    			String startTimeBeforeStr = year+"-"+month+"-"+day + " 00:00:00";
    			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
    			beforeCalendar = calendar;
    		}else{
    			Calendar calendar = Calendar.getInstance();
    			int year = calendar.get(Calendar.YEAR);
    			int month = calendar.get(Calendar.MONTH) + 1;
    			int day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    			String startTimeAfterStr = year+"-"+month+"-"+day + " 23:59:59";
    			dto.setStartTimeAfter(sdf.parse(startTimeAfterStr));
    			
    			calendar.setTime(dto.getStartTimeAfter());
    			calendar.add(Calendar.MONTH, -11);
    			year = calendar.get(Calendar.YEAR);
    			month = calendar.get(Calendar.MONTH) + 1;
    			day = 1;
    			String startTimeBeforeStr = year+"-"+month+"-"+day + " 00:00:00";
    			dto.setStartTimeBefore(sdf.parse(startTimeBeforeStr));
    			beforeCalendar = calendar;
    		}
    		//总数、拨通数、未拨通数
    		if(StringUtils.isNotEmpty(dto.getCallCheck())){
    			if(dto.getCallCheck().indexOf("0") >= 0){
    				dto.setCallTotalCheck("0");
    			}
				if(dto.getCallCheck().indexOf("1") >= 0){
    				dto.setCallInCheck("1");
    			}
				if(dto.getCallCheck().indexOf("2") >= 0){
    				dto.setCallOutCheck("2");
    			}
    		}else{
    			dto.setCallTotalCheck("0");
    			dto.setCallInCheck("1");
    			dto.setCallOutCheck("2");
    		}
    		//将要查询的日期存入Dto中
    		dto = setSearchMonth(dto, beforeCalendar, searchMonth);
    		User user=ShiroUtil.getCurrentUser();
    		dto.setMerchantId(user.getMerchantId());
    		response = telRecordServiceFacade.findMonthPageByDto(dto, PageUtil.begin(page, limit),limit);
    		List<TelRecordExtendDto> recordDtoList = response.getRows();
    		if(null != recordDtoList && recordDtoList.size() > 0){
    			for(TelRecordExtendDto recordDto: recordDtoList){
    				recordDto.setMonthOneTime(dto.getMonthOneTime());
    				recordDto.setMonthTwoTime(dto.getMonthTwoTime());
    				recordDto.setMonthThreeTime(dto.getMonthThreeTime());
    				recordDto.setMonthFourTime(dto.getMonthFourTime());
    				recordDto.setMonthFiveTime(dto.getMonthFiveTime());
    				recordDto.setMonthSixTime(dto.getMonthSixTime());
    				recordDto.setMonthSevenTime(dto.getMonthSevenTime());
    				recordDto.setMonthEightTime(dto.getMonthEightTime());
    				recordDto.setMonthNineTime(dto.getMonthNineTime());
    				recordDto.setMonthTenTime(dto.getMonthTenTime());
    				recordDto.setMonthElevenTime(dto.getMonthElevenTime());
    				recordDto.setMonthTwelveTime(dto.getMonthTwelveTime());
    			}
    			response.setRows(recordDtoList);
    		}
		} catch (Exception e) {
			logger.error(e.toString(),e);
		}
    	return response;
    }
	
	/**
	 * 从最早的那天开始查询查询后续7天的通话量(包含当天)
	 * @param dto
	 * @param calendar
	 * @param searchDays
	 * @return
	 */
	public TelRecordExtendDto setSearchDays(TelRecordExtendDto dto, Calendar calendar, int searchDays){
		for(int ii=0; ii<searchDays; ii++){
			if(ii!=0){
				calendar.add(Calendar.DAY_OF_MONTH, 1);
			}
			int year = calendar.get(Calendar.YEAR);
			int month = calendar.get(Calendar.MONTH) + 1;
			int day = calendar.get(Calendar.DAY_OF_MONTH);
			String yearStr = String.valueOf(year);
			String monthStr = String.valueOf(month);
			String dayStr = String.valueOf(day);
			if(month < 10){
				monthStr = "0"+monthStr;
			}
			if(day < 10){
				dayStr = "0" + dayStr;
			}
			String filterDay = yearStr + "-" + monthStr + "-" + dayStr;
			switch (ii) {
			case 0:
				dto.setDayOneTime(filterDay);
				break;
			case 1:
				dto.setDayTwoTime(filterDay);
				break;
			case 2:
				dto.setDayThreeTime(filterDay);
				break;
			case 3:
				dto.setDayFourTime(filterDay);
				break;
			case 4:
				dto.setDayFiveTime(filterDay);
				break;
			case 5:
				dto.setDaySixTime(filterDay);
				break;
			case 6:
				dto.setDaySevenTime(filterDay);
				break;
			default:
				break;
			}
		}
		return dto;
	}
	
	/**
	 * 从最早的那周开始查询查询后续4周的通话量(包含当周)
	 * @param dto
	 * @param calendar
	 * @param searchDays
	 * @return
	 */
	public TelRecordExtendDto setSearchWeeks(TelRecordExtendDto dto, Calendar calendar, int searchWeeks){
		for(int ii=0; ii<searchWeeks; ii++){
			if(ii!=0){
				calendar.add(Calendar.DAY_OF_MONTH, 7);
			}
			int year = calendar.get(Calendar.YEAR);
			//每年的第几周，从1开始
			//mySql中，每年的第几周从0开始，两者之间需要换算
			int week = calendar.get(Calendar.WEEK_OF_YEAR) - 1;
			int month = calendar.get(Calendar.MONTH) + 1;
			int day = calendar.get(Calendar.DAY_OF_MONTH);
			String yearStr = String.valueOf(year);
			String monthStr = String.valueOf(month);
			String dayStr = String.valueOf(day);
			String weekStr = String.valueOf(week);
			if(week < 10){
				weekStr = "0" + weekStr;
			}
			String filterDay = yearStr + "" + weekStr;
			switch (ii) {
			case 0:
				dto.setWeekOneTime(filterDay);
				break;
			case 1:
				dto.setWeekTwoTime(filterDay);
				break;
			case 2:
				dto.setWeekThreeTime(filterDay);
				break;
			case 3:
				dto.setWeekFourTime(filterDay);
				break;
			default:
				break;
			}
		}
		return dto;
	}
	
	/**
	 * 获取字段限制的时间范围值
	 * @param dto
	 * @param calendar
	 * @param searchDays
	 * @return
	 */
	public TelRecordExtendDto setSearchWeeksRange(TelRecordExtendDto dto, Calendar calendar, int searchWeeks){
		for(int ii=0; ii<searchWeeks; ii++){
			if(ii!=0){
				calendar.add(Calendar.DAY_OF_MONTH, 1);
			}
			int firMonth = calendar.get(Calendar.MONTH) + 1;
			int firDay = calendar.get(Calendar.DAY_OF_MONTH);
			String firDayStr = String.valueOf(firDay);
			if(firDay < 10){
				firDayStr = "0"+firDayStr;
			}
			calendar.add(Calendar.DAY_OF_MONTH, 6);
			int secMonth = calendar.get(Calendar.MONTH) + 1;
			int secDay = calendar.get(Calendar.DAY_OF_MONTH);
			String secDayStr = String.valueOf(secDay);
			if(secDay < 10){
				secDayStr = "0"+secDayStr;
			}
			
			String filterDay = firMonth+"."+firDayStr+"-"+secMonth+"."+secDayStr;
			switch (ii) {
			case 0:
				dto.setWeekOneTimeRange(filterDay);
				break;
			case 1:
				dto.setWeekTwoTimeRange(filterDay);
				break;
			case 2:
				dto.setWeekThreeTimeRange(filterDay);
				break;
			case 3:
				dto.setWeekFourTimeRange(filterDay);
				break;
			default:
				break;
			}
		}
		return dto;
	}
	
	/**
	 * 从最早的那月开始查询查询后续12月的通话量(包含当月)
	 * @param dto
	 * @param calendar
	 * @param searchDays
	 * @return
	 */
	public TelRecordExtendDto setSearchMonth(TelRecordExtendDto dto, Calendar calendar, int searchMonth){
		for(int ii=0; ii<searchMonth; ii++){
			if(ii!=0){
				calendar.add(Calendar.MONTH, 1);
			}
			int year = calendar.get(Calendar.YEAR);
			int month = calendar.get(Calendar.MONTH) + 1;
			String yearStr = String.valueOf(year);
			String monthStr = String.valueOf(month);
			if(month < 10){
				monthStr = "0"+monthStr;
			}
			String filterDay = yearStr + "-" + monthStr;
			switch (ii) {
			case 0:
				dto.setMonthOneTime(filterDay);
				break;
			case 1:
				dto.setMonthTwoTime(filterDay);
				break;
			case 2:
				dto.setMonthThreeTime(filterDay);
				break;
			case 3:
				dto.setMonthFourTime(filterDay);
				break;
			case 4:
				dto.setMonthFiveTime(filterDay);
				break;
			case 5:
				dto.setMonthSixTime(filterDay);
				break;
			case 6:
				dto.setMonthSevenTime(filterDay);
				break;
			case 7:
				dto.setMonthEightTime(filterDay);
				break;
			case 8:
				dto.setMonthNineTime(filterDay);
				break;
			case 9:
				dto.setMonthTenTime(filterDay);
				break;
			case 10:
				dto.setMonthElevenTime(filterDay);
				break;
			case 11:
				dto.setMonthTwelveTime(filterDay);
				break;
			default:
				break;
			}
		}
		return dto;
	}
	
	/**
	 * 将秒换算成小时:分钟:秒
	 * @param seconds
	 * @return
	 */
	public String changeSecondsToHMS(int seconds){
		String result = "00:00:00";
		if(0 != seconds){
			int h=seconds/3600;
			int m=(seconds%3600)/60;
			int s=(seconds%3600)%60;
			String hourStr = ""+h;
			String minuteStr = ""+m;
			String secondsStr = ""+s;
			if(h<10){
				hourStr = "0"+h;
			}
			if(m<10){
				minuteStr = "0"+m;
			}
			if(s<10){
				secondsStr = "0"+s;
			}
			result = hourStr+":"+minuteStr+":"+secondsStr;
		}
		return result;
	}
}
